﻿<%@ Page Language="C#" MasterPageFile="~/Template.master"AutoEventWireup="true"
    EnableViewState="false" CodeFile="Brand.aspx.cs" Inherits="Brand" Culture="auto"
    meta:resourcekey="PageResource1" UICulture="auto" %>

<%@ Register Assembly="Winthusiasm.HtmlEditor" Namespace="Winthusiasm.HtmlEditor"
    TagPrefix="mis" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="Content1" EnableViewState="false" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" EnableViewState="false" ContentPlaceHolderID="ContentPlaceHolder1"
    runat="Server">
    <div class="ContentPanel">
        <table style="width: 100%">
            <tr>
                <td style="width: 90%" class="ContentPanel">
                    <div runat="server" id="CategoryTitleLabel" class="CategoryTitleLabel">
                        <%= CustomProviders.BrandSiteMapProvider.CurrentSiteMapNode.Title %><asp:TextBox
                            Visible="False" runat="server" CssClass="TitleTextBox" ID="CategoryTitleTextBox"
                            meta:resourcekey="CategoryTitleTextBoxResource1"></asp:TextBox></div>
                    <%= CustomProviders.BrandSiteMapProvider.CurrentSiteMapNode.Description %>
                </td>
                <% if (Roles.IsUserInRole("Administrator"))
                   { %><td style="width: 40px">
                       <asp:ImageButton ID="CategoryTitleEditButton" SkinID="EditButton" runat="server"
                           OnClick="TitleEditButton_Click" meta:resourcekey="CategoryTitleEditButtonResource1">
                       </asp:ImageButton>
                   </td>
                <% } %></tr>
        </table>
        <mis:HtmlEditor EnableViewState="false" Visible="False" ID="DescriptionEditor" runat="server"
            OnSave="DescriptionEditor_Save" ToggleMode="ToggleButton" ToolbarButtonsBottom="Bold,Italic,Underline,Left,Center,Right,Justify,OrderedList,BulletedList,Indent,Outdent,Rule,Subscript,Superscript,Link,Image,Save"
            BackColor="White" ButtonMouseOverBorderColor="Black" ButtonMouseOverColor="LightYellow"
            ContextChanged="" EditorBackColor="White" EditorBorderColor="SteelBlue" EditorForeColor="Black"
            Height="300px" meta:resourcekey="DescriptionEditorResource1" ModifiedChanged=""
            SelectedTabBackColor="SteelBlue" TabBackColor="LightSteelBlue" TabbarBackColor="White"
            TabForeColor="LightYellow" TabMouseOverColor="LightBlue" Text="" ToolbarColor="SteelBlue"
            Width="500px" />
    </div>
    <asp:ListView ID="CategoryListView" runat="server" EnableViewState="false" DataKeyNames="CategoryId"
        DataSourceID="CategoriesListDS" GroupItemCount="2">
        <LayoutTemplate>
            <div id="CategoryHeader" class="BoxTitle">
                <table width="100%">
                    <tr>
                        <td>
                            <asp:Literal runat="server" ID="CategoryListTitleLabel" meta:resourcekey="CategoryListTitleLabel" /><%= CustomProviders.BrandSiteMapProvider.CurrentSiteMapNode.Title %>
                        </td>
                </table>
            </div>
            <div class="BoxContent">
            
                <table cellpadding="0" cellspacing="0" border="0"
                    style="width: 100%">
                    <asp:PlaceHolder ID="groupPlaceholder" runat="server" />
                </table>
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <td id="Td1" runat="server" style="width: 50%">
                <table class="CategoryLink">
                    <tr>
                        <td>
                            <a href='<%# string.Format("Category.aspx?id={0}", Eval("CategoryId")) %>'>
                                <%# Eval("Title") %></a>
                        </td>
                        <% if (Roles.IsUserInRole("Administrator"))
                           { %><td style="width: 7%">
                               <asp:ImageButton ID="EditButton" CommandName="Edit" SkinID="EditButton" runat="server"
                                   meta:resourcekey="EditButtonResource2" />
                           </td>
                        <% } %></tr>
                </table>
            </td>
        </ItemTemplate>
        <GroupTemplate>
            <tr>
                <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
            </tr>
        </GroupTemplate>
        <EditItemTemplate>
            <% if (Roles.IsUserInRole("Administrator"))
               { %><td style="width: 50%">
                   <table cellpadding="0" cellspacing="0" width="100%">
                       <tr>
                           <td>
                               &nbsp;&nbsp;<asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'
                                   meta:resourcekey="TitleTextBoxResource2" />
                           </td>
                           <td style="width: 14%">
                               <asp:ImageButton EnableViewState="false" ID="UpdateButton" SkinID="UpdateButton"
                                   runat="server" CommandName="Update" meta:resourcekey="UpdateButtonResource1" />
                               <asp:ImageButton ID="CancelButton" runat="server" CommandName="Cancel" SkinID="CancelButton"
                                   meta:resourcekey="CancelButtonResource1" />
                           </td>
                       </tr>
                   </table>
               </td>
            <% } %>
        </EditItemTemplate>
    </asp:ListView>
    <asp:ObjectDataSource EnableViewState="false" ID="CategoriesListDS" runat="server"
        SelectMethod="GetCategories" TypeName="DAL.Brand">
        <SelectParameters>
            <asp:QueryStringParameter Name="brandId" QueryStringField="id" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <div class="BoxTitle">
        <table width="100%">
            <tr>
                <td>
                    <asp:Literal EnableViewState="false" runat="server" ID="ProductListTitleLabel" meta:resourcekey="ProductListTitleLabel" /><%= CustomProviders.BrandSiteMapProvider.CurrentSiteMapNode.Title %>
                </td>
            </tr>
        </table>
    </div>
    <div class="BoxContent">
        <asp:ListView ID="ProductList" EnableViewState="false" DataKeyNames="ProductId" runat="server"
            DataSourceID="ProductListDS" OnItemCommand="ProductList_ItemCommand">
            <LayoutTemplate>
                <div style="text-align: center;">
                    <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
                </div>
                <div style="text-align: center">
                    <asp:DataPager ID="DataPager1" runat="server">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonCssClass="PagerNumButton" FirstPageImageUrl="~/Images/button_first.gif"
                                LastPageImageUrl="~/Images/button_last.gif" ButtonType="Image" FirstPageText="First"
                                LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" ShowFirstPageButton="True"
                                ShowNextPageButton="False" ShowPreviousPageButton="False" meta:resourcekey="Pager" />
                            <asp:NumericPagerField NextPreviousButtonCssClass="PagerNumButton" NextPageText="..."
                                PreviousPageText="..." ButtonCount="15" NumericButtonCssClass="PagerNumButton"
                                CurrentPageLabelCssClass="PagerNumButton" meta:resourcekey="NumericPagerFieldResource1" />
                            <asp:NextPreviousPagerField ButtonCssClass="PagerNumButton" FirstPageImageUrl="~/Images/button_first.gif"
                                LastPageImageUrl="~/Images/button_last.gif" ButtonType="Image" FirstPageText="First"
                                LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" ShowLastPageButton="True"
                                ShowNextPageButton="False" ShowPreviousPageButton="False" meta:resourcekey="Pager" />
                        </Fields>
                    </asp:DataPager>
                </div>
            </LayoutTemplate>
            <ItemTemplate>
                <table cellpadding="0" cellspacing="0" class="ProductListItem">
                    <tr>
                        <td style="vertical-align: middle; width: 88px; height: 88px">
                            <table style="width: 87px; height: 87px">
                                <tr>
                                    <td>
                                        <a href='<%# String.Format("Product.aspx?id={0}", Eval("ProductId")) %>'>
                                            <img style="border-width: 0px" src='<%# (Eval("DefaultImageId") == null) ? string.Format("GetTumbnail.ashx?FileName={0}&BoxSize={1}&ProductId={2}",  string.Format("www.muztorg.ru/news/cat_img/{0}.jpg", Eval("ATTradeArticle")),  80, Eval("ProductId")) : string.Format("GetTumbnail.ashx?FileName={0}&BoxSize={1}", Eval("ProductImage.Url").ToString().Trim(), 80) %>' /></a>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="ProductListItemRight">
                            <a class="ProductListItemTitle" href='<%# String.Format("Product.aspx?id={0}", Eval("ProductId")) %>'>
                                <%# Eval("Title") %></a><br />
                            <asp:Literal ID="ShortProductDescription" runat="server" Text='<%# DAL.Product.GetShortDescription(Eval("Description").ToString()) %>'></asp:Literal>
                        </td>
                        <% if (Roles.IsUserInRole("Administrator"))
                           { %><td>
                               <asp:ImageButton SkinID="EditButton" CommandName="Editredirect" CommandArgument='<%# Eval("ProductId") %>'
                                   ID="EditProductButton" runat="server" meta:resourcekey="EditProductButtonResource2" />
                               <asp:ImageButton ID="DeleteProductButton" SkinID="DeleteButton" runat="server" CommandName="Delete"
                                   meta:resourcekey="DeleteProductButtonResource2" />
                               <ajax:ConfirmButtonExtender ID="ConfirmButtonExtender1" TargetControlID="DeleteProductButton"
                                   ConfirmText="Вы действительно хотите удалить этот товар?" runat="server" Enabled="True" />
                               <asp:CheckBox runat="server" ID="SelectProductCheckBox" meta:resourcekey="SelectProductCheckBoxResource2" />
                           </td>
                        <% } %></tr>
                </table>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <table cellpadding="0" cellspacing="0" class="ProductListAlternatingItem">
                    <tr>
                        <td style="vertical-align: middle; width: 88px; height: 88px">
                            <table style="width: 87px; height: 87px">
                                <tr>
                                    <td>
                                        <a href='<%# String.Format("Product.aspx?id={0}", Eval("ProductId")) %>'>
                                            <img style="border-width: 0px" src='<%# (Eval("DefaultImageId") == null) ? string.Format("GetTumbnail.ashx?FileName={0}&BoxSize={1}&ProductId={2}",  string.Format("www.muztorg.ru/news/cat_img/{0}.jpg", Eval("ATTradeArticle")),  80, Eval("ProductId")) : string.Format("GetTumbnail.ashx?FileName={0}&BoxSize={1}", Eval("ProductImage.Url").ToString().Trim(), 80) %>' /></a>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="ProductAlternatingItemRight">
                            <a class="ProductListItemTitle" href='<%# String.Format("Product.aspx?id={0}", Eval("ProductId")) %>'>
                                <%# Eval("Title") %></a><br />
                            <asp:Literal ID="ShortProductDescription" runat="server" Text='<%# DAL.Product.GetShortDescription(Eval("Description").ToString()) %>'></asp:Literal>
                        </td>
                        <% if (Roles.IsUserInRole("Administrator"))
                           { %><td>
                               <asp:ImageButton SkinID="EditButton" CommandName="Editredirect" CommandArgument='<%# Eval("ProductId") %>'
                                   ID="EditProductButton" runat="server" meta:resourcekey="EditProductButtonResource1" />
                               <asp:ImageButton ID="DeleteProductButton" SkinID="DeleteButton" runat="server" CommandName="Delete"
                                   meta:resourcekey="DeleteProductButtonResource1" />
                               <ajax:ConfirmButtonExtender ID="ConfirmButtonExtender1" TargetControlID="DeleteProductButton"
                                   ConfirmText="Вы действительно хотите удалить этот товар?" runat="server" Enabled="True" />
                               <asp:CheckBox runat="server" ID="SelectProductCheckBox" meta:resourcekey="SelectProductCheckBoxResource1" />
                           </td>
                        <% } %></tr>
                </table>
            </AlternatingItemTemplate>
        </asp:ListView>
        </div>
        <asp:LinqDataSource EnableViewState="false" ID="ProductListDS" runat="server" ContextTypeName="DAL.EShopDBDataContext"
            TableName="Products" EnableDelete="True" EnableInsert="True" Where="BrandId == @BrandId">
            <WhereParameters>
                <asp:QueryStringParameter Name="BrandId" QueryStringField="id" Type="Int32" />
            </WhereParameters>
        </asp:LinqDataSource>
</asp:Content>
